local skel = fk.CreateSkill {
  name = "lb_old__xinliao",
}

Fk:loadTranslationTable {
  ["lb_old__xinliao"] = "心缭",
  [":lb_old__xinliao"] = "结束阶段，你可以选择一名角色，其可以弃置一张<font color=#CC3131><b>♥</b></font>牌，然后其回复1点体力并横置。",

  ["#lb_old__xinliao"] = "心缭：你可以选择一名角色，其可以弃置一张<font color=#CC3131><b>♥</b></font>牌，回复1点体力并横置",
  ["#lb_old__xinliao-ask"] = "心缭：你可以弃置一张<font color=#CC3131><b>♥</b></font>牌，然后回复1点体力并横置",

  ["$lb_old__xinliao1"] = "去污除秽，请。",
  ["$lb_old__xinliao2"] = "需要提提神吗？",
}

skel:addEffect(fk.EventPhaseStart, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skel.name) and player.phase == Player.Finish
        and table.find(player.room:getAlivePlayers(), function(to)
          return not to:isNude()
        end)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local tos = table.filter(player.room:getAlivePlayers(), function(to)
      return not to:isNude()
    end)
    if #tos > 0 then
      tos = room:askToChoosePlayers(player, {
        targets = tos,
        min_num = 1,
        max_num = 1,
        skill_name = skel.name,
        cancelable = true,
        prompt = "#lb_old__xinliao",
      })
      if #tos > 0 then
        event:setCostData(self, { tos = tos })
        return true
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = event:getCostData(self).tos[1]
    local ids = room:askToDiscard(to, {
      min_num = 1,
      max_num = 1,
      include_equip = true,
      skill_name = skel.name,
      prompt = "#lb_old__xinliao-ask",
      cancelable = true,
      pattern = ".|.|heart|.|.|.|.",
    })
    if #ids > 0 and not to.dead then
      if to:isWounded() then
        room:recover {
          who = to,
          num = 1,
          skillName = skel.name,
          recoverBy = player,
        }
      end
      if not to.chained and not to.dead then
        to:setChainState(true)
      end
    end
  end,
})

return skel
